﻿@page "/BECanvas"

@using System.Diagnostics.CodeAnalysis
 @inject IJSRuntime JSRuntime

<style>

</style>


<h3>BECanvas </h3>
<BECanvas  Width="300" Height="400" @ref="_canvasReference"></BECanvas>


@code {

    private Canvas2DContext _context;

    protected BECanvasComponent _canvasReference;

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            await JSRuntime.InvokeVoidAsync("import", "./_content/Blazor.Extensions.Canvas/blazor.extensions.canvas.js");
        }
        this._context = await this._canvasReference.CreateCanvas2DAsync();

        await _context.SetLineWidthAsync(2);
        await _context.SetLineCapAsync(Blazor.Extensions.Canvas.Canvas2D.LineCap.Round);
        await _context.SetStrokeStyleAsync("black");
        await _context.BeginPathAsync();
        await _context.MoveToAsync(0, 0);
        await _context.LineToAsync(150, 150);
        await _context.StrokeAsync();

    }
}
